package com.exception;

import com.constant.BussinessResultCodeEnum;
import com.log.LoggerFactory;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;

/**
 * @Author: chihaojie
 * @Date: 2019/6/14 13:55
 * @Version 1.0
 * @Note
 */
@Data
@Slf4j
public class BusinessException extends  RuntimeException {

    private Logger serverErrorLog=LoggerFactory.getPaymentLogger(BusinessException.class);

    private int code;

    private String message;

    private String content;



    public BusinessException(int  code,String message,String content) {
        super(message);
        this.code=code;
        this.message=message;
        this.content=content;
        serverErrorLog.info("BusinessException Occured,message is  :{}",message);
        log.error("BusinessException Occured,message is  :{}",message);
    }

    public BusinessException(int  code,String message) {
        super(message);
        this.code=code;
        this.message=message;
        this.content=null;
        serverErrorLog.info("BusinessException Occured,message is  :{}",message);
        log.error("BusinessException Occured,message is  :{}",message);
    }

    public BusinessException(String message) {
        super(message);
        this.code=500;
        this.message=message;
        this.content=null;
        serverErrorLog.info("BusinessException Occured,message is  :{}",message);
        log.error("BusinessException Occured,message is  :{}",message);
    }

    public BusinessException(BussinessResultCodeEnum  resultCodeEnum) {
        super(resultCodeEnum.resultMsg);
        this.code=resultCodeEnum.resultCode;
        this.message=resultCodeEnum.resultMsg;
        this.content=null;
        serverErrorLog.info("BusinessException Occured,message is  :{}",message);
        log.error("BusinessException Occured,message is  :{}",message);
    }
}
